home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Celestin Apprentice 4
/
Apprentice-Release4.iso
/
Languages
/
PowerMacOberon 1.2
/
Source
/
Tools
/
Batch.Mod
(
.txt
)
< prev
next >
Wrap
Oberon Text
|
1995-08-22
|
2KB
|
59 lines
Syntax10.Scn.Fnt
StampElems
Alloc
22 Aug 95
MODULE Batch; (* mah
Batch execution Batch.Start ('^' | name)
If file 'name' does not exist the text trailing the command is taken as batch job.
Every line starting with a command (no leading spaces) is executed. Lines with leading
spaces are omitted. If a line starts with the char '~' the batch job is terminated.
IMPORT Texts, Oberon;
w : Texts.Writer;
PROCEDURE Start*;
S: Texts.Scanner; beg, end, time: LONGINT; res: INTEGER;
text: Texts.Text; sel: BOOLEAN; p: Oberon.ParList; ch: CHAR;
BEGIN
sel:= FALSE; Texts.OpenScanner(S, Oberon.Par.text, Oberon.Par.pos); Texts.Scan(S);
IF (S.class = Texts.Char) & (S.c = "^") THEN
Oberon.GetSelection(text, beg, end, time); sel:= TRUE;
IF time >= 0 THEN Texts.OpenScanner(S, text, beg); Texts.Scan(S) END
END;
IF (S.class # Texts.Name) & (S.class # Texts.String) THEN RETURN END;
NEW (text); Texts.Open (text, S.s);
IF sel & (text.len = 0) THEN RETURN END;
NEW (p);
IF text.len # 0 THEN
Oberon.Par.text:= text; beg:= 0
ELSE
Texts.OpenReader (S, Oberon.Par.text, Oberon.Par.pos);
REPEAT Texts.Read (S, ch) UNTIL S.eot OR (ch = CHR(13));
beg:= Texts.Pos (S)
END;
Texts.OpenReader (S, Oberon.Par.text, beg); Texts.Read (S, ch);
Texts.OpenScanner (S, Oberon.Par.text, beg); Texts.Scan (S);
WHILE (CAP(ch) >= 'A') & (CAP(ch) <= 'Z') DO
Oberon.Par.pos:= Texts.Pos (S);
(* called command could change Oberon.Par.text, so save and restore it! *)
p^:= Oberon.Par^; Oberon.Call (S.s, Oberon.Par, FALSE, res); Oberon.Par^:= p^;
IF res # 0 THEN
Texts.WriteString (w, "Call error: "); Texts.WriteInt (w, res, 0); Texts.WriteLn (w);
Texts.Append (Oberon.Log, w.buf);
RETURN
END;
Texts.OpenReader (S, Oberon.Par.text, Texts.Pos (S)-1); Texts.Read (S, ch);
REPEAT
WHILE ~S.eot & (ch # CHR(13)) DO
Texts.Read (S, ch)
END;
Texts.Read (S, ch)
UNTIL S.eot OR ((CAP(ch) >= 'A') & (CAP(ch) <= 'Z')) OR (ch= '~' );
Texts.OpenScanner (S, Oberon.Par.text, Texts.Pos (S)-1); Texts.Scan (S)
END Start;
BEGIN
Texts.OpenWriter (w)
END Batch.Start
System.ShowCommands System ~
Browser.ShowDef TextFrames ~
System.Directory *.Mod
Browser.ShowDef TextFrames ~